//
//  YCVideoListCell.m
//  LOLBox
//
//  Created by mac on 15-3-26.
//  Copyright (c) 2015年 Honey. All rights reserved.
//

#import "YCVideoListCell.h"
#import "YCVideoModel.h"
#import "UIImageView+WebCache.h"

@interface YCVideoListCell ()
@property (weak, nonatomic) IBOutlet UIImageView *imgView;
@property (weak, nonatomic) IBOutlet UILabel *imgTime;
@property (weak, nonatomic) IBOutlet UILabel *length;
@property (weak, nonatomic) IBOutlet UILabel *name;
@property (weak, nonatomic) IBOutlet UILabel *yearDay;


@end

@implementation YCVideoListCell

- (void)awakeFromNib
{
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)fillCellWithModel:(YCVideoModel *)model
{
    [_imgView sd_setImageWithURL:[NSURL URLWithString:model.img] placeholderImage:[UIImage imageNamed:@"noimage_xiangqing"]];
    //    _postTime.text = [self upTime:s];
    _name.text = model.name;
    
    _length.text = model.length;
    _imgTime.text = model.length;
    _yearDay.text = [self upTime:[NSString stringWithFormat:@"%@",model.time]];
    
    //加边框
    CALayer *layer = [self.imgView layer];
    layer.borderColor = [[UIColor grayColor] CGColor];
    layer.borderWidth = 1.2f;
}

- (NSString *)upTime:(NSString *)str
{
    NSDate *date = [NSDate dateWithTimeIntervalSince1970:[str floatValue]];
    
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    formatter.dateFormat = @"yyyy-MM-dd";
    NSString *time = [formatter stringFromDate:date];
    
    // 3.显示日期
    return [NSString stringWithFormat:@"%@", time];
    
}


@end
